package com.jhh.pay.center.service.cloud.message;

import com.alibaba.fastjson.annotation.JSONField;
import com.jhh.pay.center.model.TradeState;
import lombok.Getter;
import lombok.Setter;

import java.util.Map;

/**
 * @author tangxd
 * @Description: TODO
 * @date 2017/12/6
 */
@Getter
@Setter
public class TradeResult {
    private String sid;
    private int channelId;

    public TradeResult(TradeState state) {
        this.state = state;
    }

    public TradeResult() {}

    @JSONField(name = "state")
    private TradeState state;
    @JSONField(name = "code")
    private String code;
    @JSONField(name = "msg")
    private String msg;
    @JSONField(name = "extension")
    private Map<String, Object> extension;

    public static TradeResult create(TradeState state, String code, String msg) {
        TradeResult ar = new TradeResult(state);
        ar.setCode(code);
        ar.setMsg(msg);
        return ar;
    }

    public static TradeResult create(TradeState state, String code, String msg, String sid) {
        TradeResult ar = new TradeResult(state);
        ar.setCode(code);
        ar.setMsg(msg);
        ar.setSid(sid);
        return ar;
    }

    public static TradeResult create(TradeState state, String code, String msg, String sid, int channelId) {
        TradeResult ar = new TradeResult(state);
        ar.setCode(code);
        ar.setMsg(msg);
        ar.setSid(sid);
        ar.setChannelId(channelId);
        return ar;
    }
}
